 <html>
 <head>
 <title>z_testing_my_taylor_lecture2.f90</title>                                
                                                                                
                                           
 </head>
 <body>
PROGRAM TEST_MY_TAYLOR <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
USE MY_OWN_DA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
USE EXERCISE_LECTURE_1 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
IMPLICIT NONE <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
TYPE(MY_TAYLOR) L1,K1,L2,K2,X(2),L0,K0,XI(2) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
INTEGER EXPONENTS(2),I,J,N,MF <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
REAL(DP) MATRIX(2,2),FRAC_PHASE,PI,FRAC_TUNE,MATRIX_INV(2,2) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
REAL(DP) ALPHA0,BETA0,GAMMA0,ALPHA,BETA,GAMMA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
TYPE(MY_TAYLOR) COURANT_SNYDER <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
MF=16 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
OPEN(UNIT=MF,FILE="TWISS.TXT") <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
100  FORMAT(2(I4,1X),3(F12.8,1X)) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
PI=ATAN(1.0_DP)*4.0_DP <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
N=10 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
L1=0.25D0 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
K1=20.0D0 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
L2=0.2D0 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
K2=-K1 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
L0=0.1D0 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
K0=0.D0 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
X(1)=0.D0;X(2)=0.D0;<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594;  Set the closed orbit to zero (we know what it is here) </font><br>                                                                                                                                                                                                                                                                                                                                                           
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
X(1)=X(1) +(1.0_DP.MONO.1)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <font color="#0000FF">X(1) = X<sub>0</sub> + x<sub>1</sub></font> </font><br>                                                                                                                                                                                                                                                                                                                                           
X(2)=X(2) +(1.0_DP.MONO.2)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <font color="#0000FF">X(2) = P<sub>0</sub> + x<sub>2</sub></font> </font><br>                                                                                                                                                                                                                                                                                                                                           
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
DO I=1,10 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
 CALL QUAD_MY_TAYLOR(X,L1,K1,N)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; </font><br>                                                                                                                                                                                                                                                                                                                                                                                                        
 CALL QUAD_MY_TAYLOR(X,L0,K0,N)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <b><i><font color="#0000FF">10 Cells map computed here</font></i></b> </font><br>                                                                                                                                                                                                                                                                                                                                  
 CALL QUAD_MY_TAYLOR(X,L2,K2,N)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; </font><br>                                                                                                                                                                                                                                                                                                                                                                                                        
 CALL QUAD_MY_TAYLOR(X,L0,K0,N)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; </font><br>                                                                                                                                                                                                                                                                                                                                                                                                        
ENDDO <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
WRITE(6,*) " ONE TURN MAP FOR 10 FODO CELLS " <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
WRITE(6,*) " FIRST RAY " <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
WRITE(6,*) X(1) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
WRITE(6,*) " SECOND RAY " <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
WRITE(6,*) X(2) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
WRITE(6,*) " LINEAR MATRIX IS " <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  CALL GET_MATRIX(X,MATRIX)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <font color="#0000FF">Our cheap routine to extract the linear part from the array X </font> </font><br>                                                                                                                                                                                                                                                                                                                
WRITE(6,*)  MATRIX(1,:) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
WRITE(6,*)  MATRIX(2,:) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
FRAC_PHASE=ACOS((MATRIX(1,1)+MATRIX(2,2))/2.D0)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; </font><br>                                                                                                                                                                                                                                                                                                                                                                                        
IF(MATRIX(1,2)<0.0_DP) FRAC_PHASE=-FRAC_PHASE+2*PI<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <b><i><font color="#0000FF">Compute the fractional tune </font></i></b> </font><br>                                                                                                                                                                                                                                                                                                             
FRAC_TUNE=FRAC_PHASE/2/PI<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; </font><br>                                                                                                                                                                                                                                                                                                                                                                                                              
WRITE(6,*) FRAC_PHASE,FRAC_TUNE <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
BETA0 =  MATRIX(1,2)/SIN(FRAC_PHASE)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594;  <i><font color="#0000FF">Compute <font face="Times New Roman">&#946;<sub>0</sub></font> &nbsp; from one-turn matrix </font></i> </font><br>                                                                                                                                                                                                                                                                  
GAMMA0= -MATRIX(2,1)/SIN(FRAC_PHASE)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594;  <i><font color="#0000FF">Compute <font face="Times New Roman">&#947;<sub>0</sub></font>  &nbsp; from one-turn matrix </font></i> </font><br>                                                                                                                                                                                                                                                                 
ALPHA0= (MATRIX(1,1)-COS(FRAC_PHASE))/SIN(FRAC_PHASE)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594;  <i><font color="#0000FF">Compute <font face="Times New Roman">&#945;<sub>0</sub></font> &nbsp; from one-turn matrix </font></i> </font><br>                                                                                                                                                                                                                                                 
WRITE(6,*) " GAMMA0,BETA0,2*ALPHA0 " <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
WRITE(6,*) GAMMA0,BETA0,2*ALPHA0 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
WRITE(6,*) (1.0_DP+ALPHA0**2)/BETA0/GAMMA0 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
COURANT_SNYDER=GAMMA0*X(1)**2+BETA0*X(2)**2+2.0_DP*ALPHA0*X(1)*X(2)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <b><i><font color="#0000FF">Compute</font></i></b><b><font color="#0000FF"><i> Courant-Snyder Invariant as a </i></font><i><font color="#FF00FF">MY_TAYLOR</font><font color="#0000FF">&nbsp; polynomial </font></i></b> </font><br>                                                                                                                                           
WRITE(6,*) " CHECKING THE INVARIANCE OF THE COURANT-SNYDER INVARIANT "<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <b><i><font color="#0000FF">and print it.</font></i></b> </font><br>                                                                                                                                                                                                                                                                                                        
WRITE(6,*) COURANT_SNYDER <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
X(1)=0.D0;X(2)=0.D0; <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
X(1)=X(1) +(1.0_DP.MONO.1) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
X(2)=X(2) +(1.0_DP.MONO.2) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
DO I=1,10 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                             CALL GET_TWISS(X,GAMMA0,BETA0,ALPHA0,GAMMA,BETA,ALPHA)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; This routines computes the lattice function </font><br>                                                                                                                                                                                                                                                                                                        
                             WRITE(MF,100) I,1,GAMMA,BETA,ALPHA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
 CALL QUAD_MY_TAYLOR(X,L1,K1,N) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                             CALL GET_TWISS(X,GAMMA0,BETA0,ALPHA0,GAMMA,BETA,ALPHA)<font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; Click <a href="#GET_TWISS">here</a> to go to get_twiss </font><br>                                                                                                                                                                                                                                                                                             
                             WRITE(MF,100) I,2,GAMMA,BETA,ALPHA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
 CALL QUAD_MY_TAYLOR(X,L0,K0,N) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                             CALL GET_TWISS(X,GAMMA0,BETA0,ALPHA0,GAMMA,BETA,ALPHA) <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
                             WRITE(MF,100) I,3,GAMMA,BETA,ALPHA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
 CALL QUAD_MY_TAYLOR(X,L2,K2,N) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                             CALL GET_TWISS(X,GAMMA0,BETA0,ALPHA0,GAMMA,BETA,ALPHA) <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
                             WRITE(MF,100) I,4,GAMMA,BETA,ALPHA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
 CALL QUAD_MY_TAYLOR(X,L0,K0,N) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
ENDDO <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
                             CALL GET_TWISS(X,GAMMA0,BETA0,ALPHA0,GAMMA,BETA,ALPHA) <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
                             WRITE(MF,100) 0,1,GAMMA,BETA,ALPHA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
CLOSE(MF) <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
END PROGRAM TEST_MY_TAYLOR <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="QUAD_MY_TAYLOR"></a>
<font color="#FF0000">SUBROUTINE QUAD_MY_TAYLOR(X,L,K,N) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USE MY_OWN_DA</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER N,I</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TYPE(MY_TAYLOR) K,L,X(2),DL</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DL=L/N</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO I=1,N</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X(1)=X(1)+DL*X(2)/SQRT(1.D0-X(2)**2)</font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; This is a simple first order drift-kick integrator </font><br>                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X(2)=X(2)-DL*K*X(1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                        
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">END SUBROUTINE QUAD_MY_TAYLOR </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                    
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="INV_MATRIX"></a>
<font color="#FF0000">SUBROUTINE INV_MATRIX(MAT,MATI) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USE MY_OWN_DA</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;REAL(DP) DET,MAT(2,2),MATI(2,2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DET=MAT(1,1)*MAT(2,2)-MAT(1,2)*MAT(2,1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MATI(1,1)=MAT(2,2)/DET</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MATI(2,2)=MAT(1,1)/DET</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MATI(1,2)=-MAT(1,2)/DET</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MATI(2,1)=-MAT(2,1)/DET</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">END SUBROUTINE INV_MATRIX </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                        
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="GET_MATRIX"></a>
<font color="#FF0000">SUBROUTINE GET_MATRIX(X,MATRIX) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USE MY_OWN_DA</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TYPE(MY_TAYLOR) X(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;REAL(DP) MATRIX(2,2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER I,J,EXPONENTS(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO I=1,2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO J=1,2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPONENTS=0</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPONENTS(J)=1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MATRIX(I,J)=X(I).SUB.EXPONENTS</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">END SUBROUTINE GET_MATRIX </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                        
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="MAKE_RAYS_WITH_MATRIX"></a>
<font color="#FF0000">SUBROUTINE MAKE_RAYS_WITH_MATRIX(MATRIX,X) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USE MY_OWN_DA</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TYPE(MY_TAYLOR) X(2),X_1,X_2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;REAL(DP) MATRIX(2,2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X_1=1.0_DP.MONO.1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X_2=1.0_DP.MONO.2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X(1)=MATRIX(1,1)*X_1+MATRIX(1,2)*X_2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X(2)=MATRIX(2,1)*X_1+MATRIX(2,2)*X_2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">END SUBROUTINE MAKE_RAYS_WITH_MATRIX </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                             
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="GET_TWISS"></a>
<font color="#FF0000">SUBROUTINE GET_TWISS(X,GAMMA0,BETA0,ALPHA0,GAMMA,BETA,ALPHA) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USE MY_OWN_DA</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TYPE(MY_TAYLOR) X(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;REAL(DP) GAMMA0,BETA0,ALPHA0,GAMMA,BETA,ALPHA</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TYPE(MY_TAYLOR) COURANT_SNYDER,XI(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;REAL(DP) MATRIX(2,2),MATRIX_INV(2,2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER EXPONENTS(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CALL GET_MATRIX(X,MATRIX)</font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; X(2) contains the nonlinear map from 0 to i. The linear part is put matrix(2,2) </font><br>                                                                                                                                                                                                                                                                         
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CALL INV_MATRIX(MATRIX,MATRIX_INV)</font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594;  matrix  is inverted into matrix_inv </font><br>                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CALL MAKE_RAYS_WITH_MATRIX(MATRIX_INV,XI)</font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594;  matrix_inv  is converted into two first degree polynomials, <font face="Times New Roman"><font size="5">xi = M<sub>0i</sub><sup>-1</sup></font><b>X</b><font size="5"></font></font> </font><br>                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COURANT_SNYDER=GAMMA0*XI(1)**2+BETA0*XI(2)**2+2.0_DP*ALPHA0*XI(1)*XI(2)</font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; <font face="Times New Roman"><font size="5">&#949;</font><sup>1<font size="5">(</font></sup><b> X</b><sup> <font size="5">&nbsp;)</font></sup>= <font size="5">&#949;</font><sup>0 </sup><font size="5">(M<sub>0i</sub><sup>-1</sup></font><b>X</b><font size="5">  )</font></font> </font><br>                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPONENTS(1)=2;EXPONENTS(2)=0;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GAMMA=COURANT_SNYDER.SUB.EXPONENTS</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                        
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPONENTS(1)=0;EXPONENTS(2)=2;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BETA=COURANT_SNYDER.SUB.EXPONENTS</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                         
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPONENTS(1)=1;EXPONENTS(2)=1;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ALPHA=(COURANT_SNYDER.SUB.EXPONENTS)/2.0_DP</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">END SUBROUTINE GET_TWISS </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                         
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 </body>
 </html>
